/**
 * Created by ZFL on 2017/12/21.
 */
function appInit(){
    PageInit();
}
var serialId ='';
var PageInit = function () {
    if($.getPara("serialId")!=''){
        serialId = $.getPara("serialId");
        expect();
    }
};

//加载期详情
function  expect(){
    $.ajaxHandler({
            model: function () {
                var obj ={};
                obj.serialId =serialId;
                if(com_obj.userId&& com_obj.userId>0){
                    obj.userId  = com_obj.userId;
                }else{
                    obj.userId  = 0;
                }
                return obj;
            },
            visibleTime:0,
            visible:'show',
            approve:true,
            dataType: "json",
            api: 'yg_baijiaapp/serial/nomalSrialDetail',
            success: function (result) {
                //console.log(result);
                var data = result.data;
                if (result.code == 10000) {
                    //商品列表
                    var goods  = data.goodsList;
                    if(goods.length>0){
                        var array=[];
                        $.each(goods,function (index,item) {
                            var obj={};
                            if(item.goodsImage.toString().indexOf("http")<=-1){
                                obj.goodsImage=$.imgApi()+item.goodsImage;
                            }else {
                                obj.goodsImage=''+item.goodsImage;
                            }
                            obj.goodsId=item.goodsId;
                            obj.picShow=false;
                            if(item.goodsChannel==3){
                                obj.picShow=true;
                            }
                            obj.name=item.name;
                            obj.labelName=item.labelName;
                            obj.priceShow=true;
                            if(item.lowestPrice>=item.suggestedPrice){
                                obj.priceShow=false;
                            }
                            obj.lowestPrice=divideNumber(item.lowestPrice,100);
                            obj.suggestedPrice=divideNumber(item.suggestedPrice,100);
                            array.push(obj);
                        });
                        var cobj={};
                        cobj.data=array;
                        var source=$("#hotGoods-template").html();
                        var template=Handlebars.compile(source);
                        $(".hot-list-box").html(template(cobj));
                    }else{
                        $('.hot-list-box').html('<p style="text-align: center;margin-top:3rem;"><img src="../src/images/search/zanwushuju@1x.png" ></p>');
                    }
                }else {
                    $.toast('异常');
                }

            }
        }
    );
}




